
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>4.1. (@)computed · MobX 中文文档</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="autorun.html" />
    
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"SangKa","repo":"MobX-Docs-CN","type":"star","size":"small","count":true},{"user":"SangKa","repo":"MobX-Docs-CN","type":"fork","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    1. MobX 介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../intro/overview.html">
            
                <a href="../intro/overview.html">
            
                    
                    1.1. MobX 要点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="../intro/concepts.html">
            
                <a href="../intro/concepts.html">
            
                    
                    1.2. 概念与原则
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="api.html">
            
                <a href="api.html">
            
                    
                    2. API概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    3. observable 相关
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="observable.html">
            
                <a href="observable.html">
            
                    
                    3.1. observable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="observable-decorator.html">
            
                <a href="observable-decorator.html">
            
                    
                    3.2. @observable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="object.html">
            
                <a href="object.html">
            
                    
                    3.3. objects
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="array.html">
            
                <a href="array.html">
            
                    
                    3.4. arrays
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="map.html">
            
                <a href="map.html">
            
                    
                    3.5. maps
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="boxed.html">
            
                <a href="boxed.html">
            
                    
                    3.6. boxed values
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="modifiers.html">
            
                <a href="modifiers.html">
            
                    
                    3.7 decorators
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    4. 对 observables 作出响应
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="computed-decorator.html">
            
                <a href="computed-decorator.html">
            
                    
                    4.1. (@)computed
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="autorun.html">
            
                <a href="autorun.html">
            
                    
                    4.2. autorun
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="when.html">
            
                <a href="when.html">
            
                    
                    4.3. when
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="reaction.html">
            
                <a href="reaction.html">
            
                    
                    4.4. reaction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="observer-component.html">
            
                <a href="observer-component.html">
            
                    
                    4.5. (@)observer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../best/react.html">
            
                <a href="../best/react.html">
            
                    
                    4.6. 理解 MobX 对何作出响应
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    5. 改变 observables
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="action.html">
            
                <a href="action.html">
            
                    
                    5.1. action
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../best/actions.html">
            
                <a href="../best/actions.html">
            
                    
                    5.2. async actions & flows
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="object-api.html">
            
                <a href="object-api.html">
            
                    
                    5.3. Object api
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    6. 工具函数
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="tojson.html">
            
                <a href="tojson.html">
            
                    
                    6.1. toJS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="extend-observable.html">
            
                <a href="extend-observable.html">
            
                    
                    6.2. extendObservable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="extending.html">
            
                <a href="extending.html">
            
                    
                    6.3. createAtom
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="observe.html">
            
                <a href="observe.html">
            
                    
                    6.4. intercept & observe
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" >
            
                <a target="_blank" href="https://github.com/mobxjs/mobx-utils#frompromise">
            
                    
                    6.5. mobxUtils.fromPromise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" >
            
                <a target="_blank" href="https://github.com/mobxjs/mobx-utils#fromresource">
            
                    
                    6.6. mobxUtils.fromResource
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" >
            
                <a target="_blank" href="https://github.com/mobxjs/mobx-utils#tostream">
            
                    
                    6.7. mobxUtils.toStream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" >
            
                <a target="_blank" href="https://github.com/mobxjs/mobx-utils#fromstream">
            
                    
                    6.8. mobxUtils.fromStream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" >
            
                <a target="_blank" href="https://github.com/mobxjs/mobx-utils#now">
            
                    
                    6.9. mobxUtils.now
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="create-transformer.html">
            
                <a href="create-transformer.html">
            
                    
                    6.10. mobxUtils.createTransformer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="expr.html">
            
                <a href="expr.html">
            
                    
                    6.11. mobxUtils.expr
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="api.html">
            
                <a href="api.html">
            
                    
                    6.12. complete api overview
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <a target="_blank" href="https://github.com/mobxjs/awesome-mobx#examples">
            
                    
                    7. 博客、 视频及相关项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                    8. 贴士与技巧
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../faq/faq.html">
            
                <a href="../faq/faq.html">
            
                    
                    8.1. 常见问题解答
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../best/pitfalls.html">
            
                <a href="../best/pitfalls.html">
            
                    
                    8.2. 常见陷阱与最佳实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../best/decorators.html">
            
                <a href="../best/decorators.html">
            
                    
                    8.3. 如何(不)使用装饰器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../best/trace.html">
            
                <a href="../best/trace.html">
            
                    
                    8.4. 使用 trace 进行调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../best/store.html">
            
                <a href="../best/store.html">
            
                    
                    8.5. 定义数据存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../best/react-performance.html">
            
                <a href="../best/react-performance.html">
            
                    
                    8.6. 优化 React 组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../best/devtools.html">
            
                <a href="../best/devtools.html">
            
                    
                    8.7. 开发工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="spy.html">
            
                <a href="spy.html">
            
                    
                    8.8. spy
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../donating.html">
            
                <a href="../donating.html">
            
                    
                    9. 捐赠
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >4.1. (@)computed</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="computed"><a name="computed" class="plugin-anchor" href="#computed"><i class="fa fa-link" aria-hidden="true"></i></a>(@)computed</h1>
<p><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/lessons/javascript-derive-computed-values-and-manage-side-effects-with-mobx-reactions" target="_blank">egghead.io &#x7B2C;3&#x8BFE;: &#x8BA1;&#x7B97;&#x503C;</a></p>
<details>
    <summary style="color: white; background:green;padding:5px;margin:5px;border-radius:2px">egghead.io &#x7B2C;3&#x8BFE;: &#x8BA1;&#x7B97;&#x503C;</summary>
    <br>
    <div style="padding:5px;">
        <iframe style="border: none;" width="760" height="427" src="https://egghead.io/lessons/javascript-derive-computed-values-and-manage-side-effects-with-mobx-reactions/embed">
    </iframe></div>
    <a style="font-style:italic;padding:5px;margin:5px;" href="https://egghead.io/lessons/javascript-derive-computed-values-and-manage-side-effects-with-mobx-reactions" target="_blank">&#x5728; egghead.io &#x4E0A;&#x89C2;&#x770B;</a>
</details>

<p>&#x8BA1;&#x7B97;&#x503C;(computed values)&#x662F;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x73B0;&#x6709;&#x7684;&#x72B6;&#x6001;&#x6216;&#x5176;&#x5B83;&#x8BA1;&#x7B97;&#x503C;&#x884D;&#x751F;&#x51FA;&#x7684;&#x503C;&#x3002;
&#x6982;&#x5FF5;&#x4E0A;&#x6765;&#x8BF4;&#xFF0C;&#x5B83;&#x4EEC;&#x4E0E;excel&#x8868;&#x683C;&#x4E2D;&#x7684;&#x516C;&#x5F0F;&#x5341;&#x5206;&#x76F8;&#x4F3C;&#x3002;
&#x4E0D;&#x8981;&#x4F4E;&#x4F30;&#x8BA1;&#x7B97;&#x503C;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x6709;&#x52A9;&#x4E8E;&#x4F7F;&#x5B9E;&#x9645;&#x53EF;&#x4FEE;&#x6539;&#x7684;&#x72B6;&#x6001;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x5C0F;&#x3002;
&#x6B64;&#x5916;&#x8BA1;&#x7B97;&#x503C;&#x8FD8;&#x662F;&#x9AD8;&#x5EA6;&#x4F18;&#x5316;&#x8FC7;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x591A;&#x4F7F;&#x7528;&#x5B83;&#x4EEC;&#x3002;</p>
<p>&#x4E0D;&#x8981;&#x628A; <code>computed</code> &#x548C; <code>autorun</code> &#x641E;&#x6DF7;&#x3002;&#x5B83;&#x4EEC;&#x90FD;&#x662F;&#x54CD;&#x5E94;&#x5F0F;&#x8C03;&#x7528;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x4F46;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x54CD;&#x5E94;&#x5F0F;&#x7684;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x88AB;&#x5176;&#x5B83; observer &#x4F7F;&#x7528;&#x7684;<strong>&#x503C;</strong>&#xFF0C;&#x8BF7;&#x4F7F;&#x7528; <code>@computed</code>&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x60F3;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x65B0;&#x503C;&#xFF0C;&#x800C;&#x60F3;&#x8981;&#x8FBE;&#x5230;&#x4E00;&#x4E2A;<strong>&#x6548;&#x679C;</strong>&#xFF0C;&#x8BF7;&#x4F7F;&#x7528; <code>autorun</code>&#x3002;
&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C;&#x6548;&#x679C;&#x662F;&#x50CF;&#x6253;&#x5370;&#x65E5;&#x5FD7;&#x3001;&#x53D1;&#x8D77;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#x7B49;&#x8FD9;&#x6837;&#x547D;&#x4EE4;&#x5F0F;&#x7684;&#x526F;&#x4F5C;&#x7528;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4EFB;&#x4F55;&#x5F71;&#x54CD;&#x8BA1;&#x7B97;&#x503C;&#x7684;&#x503C;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x4E86;&#xFF0C;&#x8BA1;&#x7B97;&#x503C;&#x5C06;&#x6839;&#x636E;&#x72B6;&#x6001;&#x81EA;&#x52A8;&#x8FDB;&#x884C;&#x884D;&#x751F;&#x3002;
&#x8BA1;&#x7B97;&#x503C;&#x5728;&#x5927;&#x591A;&#x6570;&#x60C5;&#x51B5;&#x4E0B;&#x53EF;&#x4EE5;&#x88AB; MobX &#x4F18;&#x5316;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;&#x7EAF;&#x51FD;&#x6570;&#x3002;
&#x4F8B;&#x5982;&#xFF0C;&#x5982;&#x679C;&#x524D;&#x4E00;&#x4E2A;&#x8BA1;&#x7B97;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x6570;&#x636E;&#x6CA1;&#x6709;&#x66F4;&#x6539;&#xFF0C;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x5C06;&#x4E0D;&#x4F1A;&#x91CD;&#x65B0;&#x8FD0;&#x884C;&#x3002;
&#x5982;&#x679C;&#x67D0;&#x4E2A;&#x5176;&#x5B83;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x6216; reaction &#x672A;&#x4F7F;&#x7528;&#x8BE5;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#xFF0C;&#x4E5F;&#x4E0D;&#x4F1A;&#x91CD;&#x65B0;&#x8FD0;&#x884C;&#x3002;
&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5B83;&#x5C06;&#x88AB;&#x6682;&#x505C;&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x81EA;&#x52A8;&#x5730;&#x6682;&#x505C;&#x662F;&#x975E;&#x5E38;&#x65B9;&#x4FBF;&#x7684;&#x3002;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x8BA1;&#x7B97;&#x503C;&#x4E0D;&#x518D;&#x88AB;&#x89C2;&#x5BDF;&#x4E86;&#xFF0C;&#x4F8B;&#x5982;&#x4F7F;&#x7528;&#x5B83;&#x7684;UI&#x4E0D;&#x590D;&#x5B58;&#x5728;&#x4E86;&#xFF0C;MobX &#x53EF;&#x4EE5;&#x81EA;&#x52A8;&#x5730;&#x5C06;&#x5176;&#x5783;&#x573E;&#x56DE;&#x6536;&#x3002;&#x800C; <code>autorun</code> &#x4E2D;&#x7684;&#x503C;&#x5FC5;&#x987B;&#x8981;&#x624B;&#x52A8;&#x6E05;&#x7406;&#x624D;&#x884C;&#xFF0C;&#x8FD9;&#x70B9;&#x548C;&#x8BA1;&#x7B97;&#x503C;&#x662F;&#x6709;&#x6240;&#x4E0D;&#x540C;&#x7684;&#x3002;
&#x5982;&#x679C;&#x4F60;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#xFF0C;&#x4F46;&#x4E0D;&#x5728; reaction &#x4E2D;&#x7684;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x5B83;&#x4E0D;&#x4F1A;&#x7F13;&#x5B58;&#x503C;&#x5E76;&#x4E14;&#x6709;&#x4E9B;&#x91CD;&#x65B0;&#x8BA1;&#x7B97;&#x770B;&#x8D77;&#x6765;&#x4F3C;&#x4E4E;&#x662F;&#x6CA1;&#x6709;&#x5FC5;&#x8981;&#x7684;&#x3002;&#x8FD9;&#x70B9;&#x6709;&#x65F6;&#x5019;&#x4F1A;&#x8BA9;&#x521A;&#x63A5;&#x89E6; MobX &#x7684;&#x4EBA;&#x4EEC;&#x5F88;&#x56F0;&#x60D1;&#x3002;
&#x7136;&#x800C;&#xFF0C;&#x5728;&#x73B0;&#x5B9E;&#x5F00;&#x53D1;&#x573A;&#x666F;&#x4E2D;&#xFF0C;&#x8FD9;&#x662F;&#x8FC4;&#x4ECA;&#x4E3A;&#x6B62;&#x6700;&#x597D;&#x7684;&#x9ED8;&#x8BA4;&#x903B;&#x8F91;&#x3002;&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x7684;&#x8BDD;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <a href="observe.html"><code>observe</code></a> &#x6216; <a href="https://github.com/mobxjs/mobx-utils#keepalive" target="_blank"><code>keepAlive</code></a> &#x6765;&#x5F3A;&#x5236;&#x4FDD;&#x6301;&#x8BA1;&#x7B97;&#x503C;&#x603B;&#x662F;&#x5904;&#x4E8E;&#x5524;&#x9192;&#x72B6;&#x6001;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x662F;&#x4E0D;&#x53EF;&#x679A;&#x4E3E;&#x7684;&#xFF0C;&#x5B83;&#x4EEC;&#x4E5F;&#x4E0D;&#x80FD;&#x5728;&#x7EE7;&#x627F;&#x94FE;&#x4E2D;&#x88AB;&#x8986;&#x76D6;&#x3002;</p>
<h2 id="computed"><a name="computed" class="plugin-anchor" href="#computed"><i class="fa fa-link" aria-hidden="true"></i></a><code>@computed</code></h2>
<p>&#x5982;&#x679C;&#x5DF2;&#x7ECF;<a href="../best/decorators.html">&#x542F;&#x7528; decorators</a> &#x7684;&#x8BDD;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x4EFB;&#x610F;&#x7C7B;&#x5C5E;&#x6027;&#x7684; getter &#x4E0A;&#x4F7F;&#x7528; <code>@computed</code> &#x88C5;&#x9970;&#x5668;&#x6765;&#x58F0;&#x660E;&#x5F0F;&#x7684;&#x521B;&#x5EFA;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> {observable, computed} <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;mobx&quot;</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OrderLine</span> </span>{
    @observable price = <span class="hljs-number">0</span>;
    @observable amount = <span class="hljs-number">1</span>;

    <span class="hljs-keyword">constructor</span>(price) {
        <span class="hljs-keyword">this</span>.price = price;
    }

    @computed get total() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.price * <span class="hljs-keyword">this</span>.amount;
    }
}
</code></pre>
<p>&#x8981;&#x4E0D;&#x4F7F;&#x7528; <code>decorate</code> &#x6765;&#x5F15;&#x5165;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> {decorate, observable, computed} <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;mobx&quot;</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OrderLine</span> </span>{
    price = <span class="hljs-number">0</span>;
    amount = <span class="hljs-number">1</span>;
    <span class="hljs-keyword">constructor</span>(price) {
        <span class="hljs-keyword">this</span>.price = price;
    }

    get total() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.price * <span class="hljs-keyword">this</span>.amount;
    }
}
decorate(OrderLine, {
    price: observable,
    amount: observable,
    total: computed
})
</code></pre>
<p><code>observable.object</code> &#x548C; <code>extendObservable</code> &#x90FD;&#x4F1A;&#x81EA;&#x52A8;&#x5C06; getter &#x5C5E;&#x6027;&#x63A8;&#x5BFC;&#x6210;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#xFF0C;&#x6240;&#x4EE5;&#x4E0B;&#x9762;&#x8FD9;&#x6837;&#x5C31;&#x8DB3;&#x591F;&#x4E86;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> orderLine = observable.object({
    price: <span class="hljs-number">0</span>,
    amount: <span class="hljs-number">1</span>,
    get total() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.price * <span class="hljs-keyword">this</span>.amount
    }
})
</code></pre>
<h2 id="&#x8BA1;&#x7B97;&#x503C;&#x7684;-setter"><a name="&#x8BA1;&#x7B97;&#x503C;&#x7684;-setter" class="plugin-anchor" href="#&#x8BA1;&#x7B97;&#x503C;&#x7684;-setter"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8BA1;&#x7B97;&#x503C;&#x7684; setter</h2>
<p>&#x8FD8;&#x53EF;&#x4EE5;&#x4E3A;&#x8BA1;&#x7B97;&#x503C;&#x5B9A;&#x4E49; setter&#x3002;&#x6CE8;&#x610F;&#x8FD9;&#x4E9B; setters &#x4E0D;&#x80FD;&#x7528;&#x6765;&#x76F4;&#x63A5;&#x6539;&#x53D8;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x7684;&#x503C;&#xFF0C;&#x4F46;&#x662F;&#x5B83;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x4F5C;&#x201C;&#x9006;&#x5411;&#x201D;&#x884D;&#x751F;&#x3002;&#x4F8B;&#x5982;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> orderLine = observable.object({
    price: <span class="hljs-number">0</span>,
    amount: <span class="hljs-number">1</span>,
    get total() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.price * <span class="hljs-keyword">this</span>.amount
    },
    set total(total) {
        <span class="hljs-keyword">this</span>.price = total / <span class="hljs-keyword">this</span>.amount <span class="hljs-comment">// &#x4ECE; total &#x4E2D;&#x63A8;&#x5BFC;&#x51FA; price</span>
    }
})
</code></pre>
<p>&#x540C;&#x6837;&#x7684;</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span> </span>{
    @observable length = <span class="hljs-number">2</span>;
    @computed get squared() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.length * <span class="hljs-keyword">this</span>.length;
    }
    set squared(value) { <span class="hljs-comment">// &#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x81EA;&#x52A8;&#x7684;&#x52A8;&#x4F5C;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x6CE8;&#x89E3;</span>
        <span class="hljs-keyword">this</span>.length = <span class="hljs-built_in">Math</span>.sqrt(value);
    }
}
</code></pre>
<p><em>&#x6CE8;&#x610F;: &#x6C38;&#x8FDC;&#x5728; getter <strong>&#x4E4B;&#x540E;</strong> &#x5B9A;&#x4E49; setter&#xFF0C;&#x4E00;&#x4E9B; TypeScript &#x7248;&#x672C;&#x4F1A;&#x77E5;&#x9053;&#x58F0;&#x660E;&#x4E86;&#x4E24;&#x4E2A;&#x5177;&#x6709;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x7684;&#x5C5E;&#x6027;&#x3002;</em></p>
<h2 id="computedexpression-&#x51FD;&#x6570;"><a name="computedexpression-&#x51FD;&#x6570;" class="plugin-anchor" href="#computedexpression-&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a><code>computed(expression)</code> &#x51FD;&#x6570;</h2>
<p><code>computed</code> &#x8FD8;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5F53;&#x505A;&#x51FD;&#x6570;&#x6765;&#x8C03;&#x7528;&#x3002;
&#x5C31;&#x50CF; <code>observable.box(primitive value)</code> &#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x72EC;&#x7ACB;&#x7684; observable&#x3002;
&#x5728;&#x8FD4;&#x56DE;&#x7684;&#x5BF9;&#x8C61;&#x4E0A;&#x4F7F;&#x7528; <code>.get()</code> &#x6765;&#x83B7;&#x53D6;&#x8BA1;&#x7B97;&#x7684;&#x5F53;&#x524D;&#x503C;&#xFF0C;&#x6216;&#x8005;&#x4F7F;&#x7528; <code>.observe(callback)</code> &#x6765;&#x89C2;&#x5BDF;&#x503C;&#x7684;&#x6539;&#x53D8;&#x3002;
&#x8FD9;&#x79CD;&#x5F62;&#x5F0F;&#x7684; <code>computed</code> &#x4E0D;&#x5E38;&#x4F7F;&#x7528;&#xFF0C;&#x4F46;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x4F20;&#x9012;&#x4E00;&#x4E2A;&#x201C;&#x5728;box&#x4E2D;&#x201D;&#x7684;&#x8BA1;&#x7B97;&#x503C;&#x65F6;&#xFF0C;&#x5B83;&#x53EF;&#x80FD;&#x662F;&#x6709;&#x7528;&#x7684;&#x3002;</p>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> {observable, computed} <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;mobx&quot;</span>;
<span class="hljs-keyword">var</span> name = observable.box(<span class="hljs-string">&quot;John&quot;</span>);

<span class="hljs-keyword">var</span> upperCaseName = computed(() =&gt;
    name.get().toUpperCase()
);

<span class="hljs-keyword">var</span> disposer = upperCaseName.observe(change =&gt; <span class="hljs-built_in">console</span>.log(change.newValue));

name.set(<span class="hljs-string">&quot;Dave&quot;</span>);
<span class="hljs-comment">// &#x8F93;&#x51FA;: &apos;DAVE&apos;</span>
</code></pre>
<h2 id="computed-&#x7684;&#x9009;&#x9879;"><a name="computed-&#x7684;&#x9009;&#x9879;" class="plugin-anchor" href="#computed-&#x7684;&#x9009;&#x9879;"><i class="fa fa-link" aria-hidden="true"></i></a><code>computed</code> &#x7684;&#x9009;&#x9879;</h2>
<p>&#x5F53;&#x4F7F;&#x7528; <code>computed</code> &#x4F5C;&#x4E3A;&#x8C03;&#x8282;&#x5668;&#x6216;&#x8005;&#x76D2;&#x5B50;&#xFF0C;&#x5B83;&#x63A5;&#x6536;&#x7684;&#x7B2C;&#x4E8C;&#x4E2A;&#x9009;&#x9879;&#x53C2;&#x6570;&#x5BF9;&#x8C61;&#xFF0C;&#x9009;&#x9879;&#x53C2;&#x6570;&#x5BF9;&#x8C61;&#x6709;&#x5982;&#x4E0B;&#x53EF;&#x9009;&#x53C2;&#x6570;:</p>
<ul>
<li><code>name</code>: &#x5B57;&#x7B26;&#x4E32;, &#x5728; spy &#x548C; MobX &#x5F00;&#x53D1;&#x8005;&#x5DE5;&#x5177;&#x4E2D;&#x4F7F;&#x7528;&#x7684;&#x8C03;&#x8BD5;&#x540D;&#x79F0;</li>
<li><code>context</code>: &#x5728;&#x63D0;&#x4F9B;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x4F7F;&#x7528;&#x7684; <code>this</code></li>
<li><code>set</code>: &#x8981;&#x4F7F;&#x7528;&#x7684;setter&#x51FD;&#x6570;&#x3002; &#x6CA1;&#x6709; setter &#x7684;&#x8BDD;&#x65E0;&#x6CD5;&#x4E3A;&#x8BA1;&#x7B97;&#x503C;&#x5206;&#x914D;&#x65B0;&#x503C;&#x3002; &#x5982;&#x679C;&#x4F20;&#x9012;&#x7ED9; <code>computed</code> &#x7684;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x628A;&#x4F1A;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x4F5C;&#x4E3A; setter</li>
<li><code>equals</code>: &#x9ED8;&#x8BA4;&#x503C;&#x662F; <code>comparer.default</code> &#x3002;&#x5B83;&#x5145;&#x5F53;&#x6BD4;&#x8F83;&#x524D;&#x4E00;&#x4E2A;&#x503C;&#x548C;&#x540E;&#x4E00;&#x4E2A;&#x503C;&#x7684;&#x6BD4;&#x8F83;&#x51FD;&#x6570;&#x3002;&#x5982;&#x679C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x8BA4;&#x4E3A;&#x524D;&#x4E00;&#x4E2A;&#x503C;&#x548C;&#x540E;&#x4E00;&#x4E2A;&#x503C;&#x662F;&#x76F8;&#x7B49;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x89C2;&#x5BDF;&#x8005;&#x5C31;&#x4E0D;&#x4F1A;&#x91CD;&#x65B0;&#x8BC4;&#x4F30;&#x3002;&#x8FD9;&#x5728;&#x4F7F;&#x7528;&#x7ED3;&#x6784;&#x6570;&#x636E;&#x548C;&#x6765;&#x81EA;&#x5176;&#x4ED6;&#x5E93;&#x7684;&#x7C7B;&#x578B;&#x65F6;&#x5F88;&#x6709;&#x7528;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x4E00;&#x4E2A; computed &#x7684; <a href="https://momentjs.com/" target="_blank">moment</a> &#x5B9E;&#x4F8B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>(a, b) =&gt; a.isSame(b)</code> &#x3002;&#x5982;&#x679C;&#x60F3;&#x8981;&#x4F7F;&#x7528;&#x7ED3;&#x6784;&#x6BD4;&#x8F83;&#x6765;&#x786E;&#x5B9A;&#x65B0;&#x7684;&#x503C;&#x662F;&#x5426;&#x4E0E;&#x4E0A;&#x4E2A;&#x503C;&#x4E0D;&#x540C; (&#x5E76;&#x4F5C;&#x4E3A;&#x7ED3;&#x679C;&#x901A;&#x77E5;&#x89C2;&#x5BDF;&#x8005;)&#xFF0C;<code>comparer.deep</code> &#x5341;&#x5206;&#x4FBF;&#x5229;&#x3002;</li>
<li><code>requiresReaction</code>: &#x5BF9;&#x4E8E;&#x975E;&#x5E38;&#x6602;&#x8D35;&#x7684;&#x8BA1;&#x7B97;&#x503C;&#xFF0C;&#x63A8;&#x8350;&#x8BBE;&#x7F6E;&#x6210; <code>true</code> &#x3002;&#x5982;&#x679C;&#x4F60;&#x5C1D;&#x8BD5;&#x8BFB;&#x53D6;&#x5B83;&#x7684;&#x503C;&#xFF0C;&#x4F46;&#x67D0;&#x4E9B;&#x89C2;&#x5BDF;&#x8005;&#x6CA1;&#x6709;&#x8DDF;&#x8E2A;&#x8BE5;&#x503C;&#xFF08;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;MobX &#x4E0D;&#x4F1A;&#x7F13;&#x5B58;&#x8BE5;&#x503C;&#xFF09;&#xFF0C;&#x5219;&#x4F1A;&#x5BFC;&#x81F4;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;&#x4E22;&#x5931;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x8FDB;&#x884C;&#x6602;&#x8D35;&#x7684;&#x91CD;&#x65B0;&#x8BC4;&#x4F30;&#x3002;</li>
<li><code>keepAlive</code>: &#x5982;&#x679C;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x4EBA;&#x89C2;&#x5BDF;&#x5230;&#xFF0C;&#x5219;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x6B64;&#x8BA1;&#x7B97;&#x503C;&#x3002; <em>&#x8BF7;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x5F88;&#x5BB9;&#x6613;&#x5BFC;&#x81F4;&#x5185;&#x5B58;&#x6CC4;&#x6F0F;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4F1A;&#x5BFC;&#x81F4;&#x6B64;&#x8BA1;&#x7B97;&#x503C;&#x4F7F;&#x7528;&#x7684;&#x6BCF;&#x4E2A; observable &#xFF0C;&#x5E76;&#x5C06;&#x8BA1;&#x7B97;&#x503C;&#x4FDD;&#x5B58;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#xFF01;</em></li>
</ul>
<h2 id="computedstruct-&#x7528;&#x4E8E;&#x6BD4;&#x8F83;&#x7ED3;&#x6784;"><a name="computedstruct-&#x7528;&#x4E8E;&#x6BD4;&#x8F83;&#x7ED3;&#x6784;" class="plugin-anchor" href="#computedstruct-&#x7528;&#x4E8E;&#x6BD4;&#x8F83;&#x7ED3;&#x6784;"><i class="fa fa-link" aria-hidden="true"></i></a><code>@computed.struct</code> &#x7528;&#x4E8E;&#x6BD4;&#x8F83;&#x7ED3;&#x6784;</h2>
<p><code>@computed</code> &#x88C5;&#x9970;&#x5668;&#x4E0D;&#x9700;&#x8981;&#x63A5;&#x6536;&#x53C2;&#x6570;&#x3002;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x80FD;&#x8FDB;&#x884C;&#x7ED3;&#x6784;&#x6BD4;&#x8F83;&#x7684;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x8BF7;&#x4F7F;&#x7528; <code>@computed.struct</code>&#x3002;</p>
<h2 id="&#x5185;&#x7F6E;&#x6BD4;&#x8F83;&#x5668;"><a name="&#x5185;&#x7F6E;&#x6BD4;&#x8F83;&#x5668;" class="plugin-anchor" href="#&#x5185;&#x7F6E;&#x6BD4;&#x8F83;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5185;&#x7F6E;&#x6BD4;&#x8F83;&#x5668;</h2>
<p>MobX &#x63D0;&#x4F9B;&#x4E86;&#x4E09;&#x4E2A;&#x5185;&#x7F6E; <code>comparer</code> (&#x6BD4;&#x8F83;&#x5668;) &#xFF0C;&#x5B83;&#x4EEC;&#x5E94;&#x8BE5;&#x80FD;&#x6EE1;&#x8DB3;&#x7EDD;&#x5927;&#x90E8;&#x5206;&#x9700;&#x6C42;&#xFF1A;</p>
<ul>
<li><code>comparer.identity</code>: &#x4F7F;&#x7528;&#x6052;&#x7B49; (<code>===</code>) &#x8FD0;&#x7B97;&#x7B26;&#x6765;&#x5224;&#x5B9A;&#x4E24;&#x4E2A;&#x503C;&#x662F;&#x5426;&#x76F8;&#x540C;&#x3002;</li>
<li><code>comparer.default</code>: &#x7B49;&#x540C;&#x4E8E; <code>comparer.identity</code>&#xFF0C;&#x4F46;&#x8FD8;&#x8BA4;&#x4E3A; <code>NaN</code> &#x7B49;&#x4E8E; <code>NaN</code> &#x3002;</li>
<li><code>comparer.structural</code>: &#x6267;&#x884C;&#x6DF1;&#x5C42;&#x7ED3;&#x6784;&#x6BD4;&#x8F83;&#x4EE5;&#x786E;&#x5B9A;&#x4E24;&#x4E2A;&#x503C;&#x662F;&#x5426;&#x76F8;&#x540C;&#x3002;</li>
</ul>
<h2 id="&#x9519;&#x8BEF;&#x5904;&#x7406;"><a name="&#x9519;&#x8BEF;&#x5904;&#x7406;" class="plugin-anchor" href="#&#x9519;&#x8BEF;&#x5904;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9519;&#x8BEF;&#x5904;&#x7406;</h2>
<p>&#x5982;&#x679C;&#x8BA1;&#x7B97;&#x503C;&#x5728;&#x5176;&#x8BA1;&#x7B97;&#x671F;&#x95F4;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#xFF0C;&#x5219;&#x6B64;&#x5F02;&#x5E38;&#x5C06;&#x6355;&#x83B7;&#x5E76;&#x5728;&#x8BFB;&#x53D6;&#x5176;&#x503C;&#x65F6;&#x91CD;&#x65B0;&#x629B;&#x51FA;&#x3002;
&#x5F3A;&#x70C8;&#x5EFA;&#x8BAE;&#x59CB;&#x7EC8;&#x629B;&#x51FA;&#x201C;&#x9519;&#x8BEF;&#x201D;&#xFF0C;&#x4EE5;&#x4FBF;&#x4FDD;&#x7559;&#x539F;&#x59CB;&#x5806;&#x6808;&#x8DDF;&#x8E2A;&#x3002; &#x4F8B;&#x5982;&#xFF1A;<code>throw new Error&#xFF08;&#x201C;Uhoh&#x201D;&#xFF09;</code>, &#x800C;&#x4E0D;&#x662F;<code>throw &quot;Uhoh&quot;</code>&#x3002;
&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x4E0D;&#x4F1A;&#x4E2D;&#x65AD;&#x8DDF;&#x8E2A;&#xFF0C;&#x6240;&#x6709;&#x8BA1;&#x7B97;&#x503C;&#x53EF;&#x4EE5;&#x4ECE;&#x5F02;&#x5E38;&#x4E2D;&#x6062;&#x590D;&#x3002;</p>
<p>&#x793A;&#x4F8B;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> x = observable.box(<span class="hljs-number">3</span>)
<span class="hljs-keyword">const</span> y = observable.box(<span class="hljs-number">1</span>)
<span class="hljs-keyword">const</span> divided = computed(() =&gt; {
    <span class="hljs-keyword">if</span> (y.get() === <span class="hljs-number">0</span>)
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&quot;Division by zero&quot;</span>)
    <span class="hljs-keyword">return</span> x.get() / y.get()
})

divided.get() <span class="hljs-comment">// &#x8FD4;&#x56DE; 3</span>

y.set(<span class="hljs-number">0</span>) <span class="hljs-comment">// OK</span>
divided.get() <span class="hljs-comment">// &#x62A5;&#x9519;: Division by zero</span>
divided.get() <span class="hljs-comment">// &#x62A5;&#x9519;: Division by zero</span>

y.set(<span class="hljs-number">2</span>)
divided.get() <span class="hljs-comment">// &#x5DF2;&#x6062;&#x590D;; &#x8FD4;&#x56DE; 1.5</span>
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="autorun.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 4.2. autorun">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"4.1. (@)computed","level":"1.4.1","depth":2,"next":{"title":"4.2. autorun","level":"1.4.2","depth":2,"path":"refguide/autorun.md","ref":"refguide/autorun.md","articles":[]},"previous":{"title":"4. 对 observables 作出响应","level":"1.4","depth":1,"ref":"","articles":[{"title":"4.1. (@)computed","level":"1.4.1","depth":2,"path":"refguide/computed-decorator.md","ref":"refguide/computed-decorator.md","articles":[]},{"title":"4.2. autorun","level":"1.4.2","depth":2,"path":"refguide/autorun.md","ref":"refguide/autorun.md","articles":[]},{"title":"4.3. when","level":"1.4.3","depth":2,"path":"refguide/when.md","ref":"refguide/when.md","articles":[]},{"title":"4.4. reaction","level":"1.4.4","depth":2,"path":"refguide/reaction.md","ref":"refguide/reaction.md","articles":[]},{"title":"4.5. (@)observer","level":"1.4.5","depth":2,"path":"refguide/observer-component.md","ref":"refguide/observer-component.md","articles":[]},{"title":"4.6. 理解 MobX 对何作出响应","level":"1.4.6","depth":2,"path":"best/react.md","ref":"best/react.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github","edit-link","anchors","copy-code-button","github-buttons"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/SangKa/mobx-docs-cn"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"github-buttons":{"buttons":[{"user":"SangKa","repo":"MobX-Docs-CN","type":"star","size":"small","count":true},{"user":"SangKa","repo":"MobX-Docs-CN","type":"fork","size":"small","count":true}]},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"完善文档","base":"https://github.com/SangKa/mobx-docs-cn/tree/master/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"MobX 中文文档","gitbook":"3.2.2"},"file":{"path":"refguide/computed-decorator.md","mtime":"2018-09-18T13:06:39.950Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-09-18T13:06:52.064Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

